<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <meta content="<?php echo ($description); ?>" name="description">
        <title>
            <?php echo ($title); ?>
        </title>
        <script type="text/javascript" src="/task/laybbs/Public/jquery-3.1.1.min.js"></script>
        <script src="/task/laybbs/Public/layui.js"></script>
        <link rel="stylesheet" href="//at.alicdn.com/t/font_001z27klwvobt9.css">
        <link rel="stylesheet" href="/task/laybbs/Public/css/layui.css">
        <link rel="stylesheet" href="/task/laybbs/Public/css/global.css">
        <link rel="shortcut icon" href="/task/laybbs/Public/images/fav.ico" type="image/x-icon"/> 
        <script type="text/javascript">
            $(function () {
                $('#logout-btn').click(function () {
                    layui.use('layer', function(){
                    var layer = layui.layer;
                                 
                    $.ajax({
                        url: "<?php echo U('home/ucenter/logout');?>",
                        type: 'POST',
                        dataType: 'json',
                    })
                    .done(function(response) {
                        if(response.info){
                            layer.msg(response.info, {icon: 6});
                            location.href = "<?php echo U('home/index/index');?>";
                        }else{
                            layer.msg('服务器出错', {icon: 5});
                        }
                    })
                    .fail(function() {
                        console.log("error");
                    });
                    }); 
                });
            });
        </script>
    </head>
    <body <?php echo ($body_tag); ?>>
        <div class="header">
            <div class="main">
                <a class="logo" href="<?php echo U('home/index/index');?>" title="Fly">
                    Fly社区
                </a>
                <div class="nav">
                    <a href="<?php echo U('home/question/qlistall');?>">
                        <i class="iconfont icon-wenda">
                        </i>
                        问答
                    </a>
                    <a href="http://fly.layui.com/case/2016/">
                        <i class="iconfont icon-iconmingxinganli" style="top: 2px;">
                        </i>
                        案例
                    </a>
                    <a href="http://www.layui.com/">
                        <i class="iconfont icon-ui">
                        </i>
                        框架
                    </a>
                </div>
                <?php
 if (!$_SESSION['nickname']) { ?>
                    <div class="nav-user">
                    <a class="unlogin" href="<?php echo U('home/login/index');?>">
                        <i class="iconfont icon-touxiang">
                        </i>
                    </a>
                    <span>
                        <a class="login-btn" href="<?php echo U('home/login/index');?>">
                            登入
                        </a>
                        <a class="reg-btn" href="<?php echo U('home/reg/index');?>">
                            注册
                        </a>
                    </span>
                    <p class="out-login">
                        <?php if(C('QQ_SWITCH')){ ?>
                        <a href="<?php echo U('/home/login/qqlogin');?>" onclick="layer.msg('正在通过QQ登入', {icon:16, shade: 0.1, time:0})"
                        class="iconfont icon-qq" title="QQ登入">
                        </a>
                        <?php } ?>
                        <a href="<?php echo U('/home/login/wblogin');?>" onclick="layer.msg('正在通过微博登入', {icon:16, shade: 0.1, time:0})"
                        class="iconfont icon-weibo" title="微博登入">
                        </a>
                    </p>
                    </div>
                <?php
 } else { ?>
                    <div class="nav-user">
                        <a href="<?php echo U('home/ucenter/index');?>" class="avatar">
                            <img src="/task/laybbs/<?php echo $_SESSION[avatar];?>" id='avatar-pic'>
                            <cite>
                                <?php echo $_SESSION['nickname'] ?>
                            </cite>
                        </a>
                        <div class="nav">
                            <a href="<?php echo U('home/ucenter/setting');?>">
                                <i class="iconfont icon-shezhi">
                                </i>
                                设置
                            </a>
                            <a href="javascript:void(0);" id="logout-btn">
                                <i style="top: 0; font-size: 22px;" class="iconfont icon-tuichu">
                                </i>
                                退了
                            </a>
                        </div>
                    </div>
                <?php } ?>
            </div>
        </div>
        <div class="main layui-clear">
    <div class="wrap">
        <div style="margin-right:0" class="content">
            <div class="fly-tab">
    <span>
        <a href="<?php echo U('/home/question/qlistall');?>" <?php if(CONTROLLER_NAME=='Question' && ACTION_NAME=='qlistall'){ echo 'class="tab-this"'; }?>>
            全部
        </a>
        <a href="<?php echo U('/home/question/qlistunsolved');?>" <?php if(CONTROLLER_NAME=='Question' && ACTION_NAME=='qlistunsolved'){ echo 'class="tab-this"'; }?>>
            未结帖
        </a>
        <a href="<?php echo U('/home/question/qlistsolved');?>" <?php if(CONTROLLER_NAME=='Question' && ACTION_NAME=='qlistsolved'){ echo 'class="tab-this"'; }?>>
            已采纳
        </a>
        <a href="<?php echo U('/home/question/qlistwonderful');?>" <?php if(CONTROLLER_NAME=='Question' && ACTION_NAME=='qlistwonderful'){ echo 'class="tab-this"'; }?>>
            精帖
        </a>
        <?php if ($_SESSION['uid']) { ?>
            <a href="<?php echo U('/home/question/qlistuser');?>" <?php if(CONTROLLER_NAME=='Question' && ACTION_NAME=='qlistuser'){ echo 'class="tab-this"'; }?>>
                我的帖
            </a>
        <?php } ?>
    </span>
    <form action="https://www.baidu.com/s" class="fly-search">
        <i class="iconfont icon-sousuo">
        </i>
        <input class="layui-input" autocomplete="off" placeholder="搜索内容，回车跳转"
        type="text" name="wd">
    </form>
    <a href="<?php echo U('/home/question/qsubmit');?>" class="layui-btn jie-add">
        发布问题
    </a>
</div>
<script type="text/javascript">
    //搜索框
    $('.fly-search').submit(function() {
        var input = $(this).find('input'),
        val = input.val();
        if (val.replace(/\s/g, '') === '') 
        input.val('site:layui.com ' + input.val());// 添加site标记，使搜索引擎指定网址的记录
    });
    $('.icon-sousuo').on('click',
    function() {
        $('.fly-search').submit();
    });
</script>
            <ul class="fly-list">
                <?php if (empty($list)) { ?>
                    <li class="fly-none">暂无内容</li>
                <?php } else { ?>
                <?php foreach ($list as $value) { ?>
                    <li class="fly-list-li">
                        <a class="fly-list-avatar" href="<?php echo U('home/center/index',array('uid'=>$value['uid']));?>">
                            <img alt="<?php echo ($value['uname']); ?>" src="/task/laybbs/<?php echo ($value['avatar']); ?>">
                        </a>
                        <h2 class="fly-tip">
                            <a href="<?php echo U('home/question/qpage',array('qid'=>$value['qid']));?>">
                                <?php echo ($value['title']); ?>
                            </a>
                            <?php if ($value['top'] == 1) { ?>
                                <span class="fly-tip-stick">置顶</span>
                            <?php } ?>
                        </h2>
                        <p>
                            <span>
                                <a href="<?php echo U('home/center/index',array('uid'=>$value['uid']));?>">
                                    <?php echo ($value['uname']); ?>
                                </a>
                            </span>
                            <span>
                                <?php echo timeFormat($value['qtime']);?>
                            </span>
                            <span>
                                <?php echo ($value['category']); ?>
                            </span>
                            <span class="fly-list-hint">
                                <i title="回答" class="iconfont">
                                    
                                </i>
                                <?php echo ($value['num_of_ans']); ?>
                                <i title="人气" class="iconfont">
                                    
                                </i>
                                <?php echo ($value['views']); ?>
                            </span>
                        </p>
                    </li>
                <?php } ?>
                <?php } ?>
            <div style="text-align: center">
                <div id="laypage-main"></div>
<script type="text/javascript">
layui.use(['laypage', 'layer'],function() {
    var laypage = layui.laypage,
    layer = layui.layer;
    var actname = '<?php echo ($actname); ?>';

    laypage({
        cont: $('#laypage-main'),
        pages: <?php echo ($allpages); ?>,
        curr: function() {
            var page = "<?php echo ($nowpage); ?>"; // 当前页(后台获取到的)
            return page ? page: 1; // 返回当前页码值
        } (),
        jump: function(e, first) { //触发分页后的回调(单击页码后)
            if (!first) { //一定要加此判断，否则初始时会无限刷新
                var urls = "<?php echo U('home/question/"+actname+"',array('page'=>'pageval'));?>";
                var nowpage = e.curr; // (被单击的页码)
                urls = urls.replace('pageval', nowpage); // 替换链接样式和页码
                window.location.href = urls;
            }
        }
    });
});
</script>
            </div>
        </div>
    </div>
</div>
        <div class="footer">
            <p>
                <a href="http://fly.layui.com/">
                    Fly社区
                </a>
                2016 &copy;
                <a href="http://www.layui.com/">
                    layui.com
                </a>
            </p>
            <p>
                <a href="http://fly.layui.com/jie/3147.html" target="_blank">
                    产品授权
                </a>
                <a href="http://fly.layui.com/jie/4536.html" target="_blank">
                    获取Fly社区模版
                </a>
                <a href="http://fly.layui.com/jie/2461.html" target="_blank">
                    微信公众号
                </a>
            </p>
        </div>
    </body>
</html>